package com.kuang.utils;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class GetTime {

    Date date1 = new Date();
    Date date2 = new Date();

    Calendar calendar = Calendar.getInstance();
//    SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    //获取当前时间
    public Date getNow(){
        return date1;
    }
    //获取前一天时间
    public Date getBefore(){
        calendar.setTime(date1);
        calendar.add(Calendar.DAY_OF_MONTH, -1);
        date2 = calendar.getTime();
        return date2;
    }

}
